package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.WcsDvc;
import com.ruoyi.system.service.IWcsDvcService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * PLC接口参数Controller
 * 
 * @author ZYT
 * @date 2020-12-21
 */
@RestController
@RequestMapping("/system/WcsDvc")
public class WcsDvcController extends BaseController
{
    @Autowired
    private IWcsDvcService wcsDvcService;

    /**
     * 查询PLC接口参数列表
     */
    @PreAuthorize("@ss.hasPermi('system:WcsDvc:list')")
    @GetMapping("/list")
    public TableDataInfo list(WcsDvc wcsDvc)
    {
        startPage();
        List<WcsDvc> list = wcsDvcService.selectWcsDvcList(wcsDvc);
        return getDataTable(list);
    }

    /**
     * 导出PLC接口参数列表
     */
    @PreAuthorize("@ss.hasPermi('system:WcsDvc:export')")
    @Log(title = "PLC接口参数", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WcsDvc wcsDvc)
    {
        List<WcsDvc> list = wcsDvcService.selectWcsDvcList(wcsDvc);
        ExcelUtil<WcsDvc> util = new ExcelUtil<WcsDvc>(WcsDvc.class);
        return util.exportExcel(list, "WcsDvc");
    }

    /**
     * 获取PLC接口参数详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:WcsDvc:query')")
    @GetMapping(value = "/{dvcId}")
    public AjaxResult getInfo(@PathVariable("dvcId") Long dvcId)
    {
        return AjaxResult.success(wcsDvcService.selectWcsDvcById(dvcId));
    }

    /**
     * 新增PLC接口参数
     */
    @PreAuthorize("@ss.hasPermi('system:WcsDvc:add')")
    @Log(title = "PLC接口参数", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WcsDvc wcsDvc)
    {
        return toAjax(wcsDvcService.insertWcsDvc(wcsDvc));
    }

    /**
     * 修改PLC接口参数
     */
    @PreAuthorize("@ss.hasPermi('system:WcsDvc:edit')")
    @Log(title = "PLC接口参数", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WcsDvc wcsDvc)
    {
        return toAjax(wcsDvcService.updateWcsDvc(wcsDvc));
    }

    /**
     * 删除PLC接口参数
     */
    @PreAuthorize("@ss.hasPermi('system:WcsDvc:remove')")
    @Log(title = "PLC接口参数", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dvcIds}")
    public AjaxResult remove(@PathVariable Long[] dvcIds)
    {
        return toAjax(wcsDvcService.deleteWcsDvcByIds(dvcIds));
    }
}
